package cn.itcast.bos.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.domain.base.Area;
import cn.itcast.bos.domain.base.Courier;
import cn.itcast.bos.repository.AreaRepository;
import cn.itcast.bos.service.AreaService;
@Service
@Transactional
public class AreaServiceImpl implements AreaService {

	@Autowired
	private AreaRepository areaRepository;

	@Override
	public void save(Area area) {
		
		areaRepository.save(area);
	}

	@Override
	public Page<Area> findPageQueryByCondition(Specification<Area> specification, PageRequest pageable) {
		
		return areaRepository.findAll(specification, pageable);
	}

	@Override
	public void deleteArea(String ids) {
		String[] list = ids.split(",");
		for (int i = 0; i < list.length; i++) {
			/*Integer id = Integer.parseInt(list[i]);
			areaRepository.delete(id);*/
			areaRepository.delete(list[i]);
		}
		
	}

	@Override
	public void saveAreas(List<Area> areas) {
		areaRepository.save(areas);
		
	}


}
